/*
 * main.cpp
 *
 *  Created on: Jul 6, 2009
 *      Author: yanir
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include "SimulatedDisk.h"
#include "FileSystem.h"
#include "SystemCallLayer.h"
#include "UI.h"

using namespace std;

int main( int argc, char *argv[] )  {


	string config_file;
	/* get the configuration file */
	if (argc == 2){
		config_file = argv[1];
	}else{
		cout<< "Not a legal number of arguments"<<endl;
	}

	/* check if FILE_SYS exists :
	 * 			-create a new one if it dose'nt exists
	 * 			-if exists , use the current one.
	*/


	ifstream inp;
	ofstream out;
	string myFileName;
	myFileName = "FILE_SYS";
	inp.open(myFileName.c_str(), ifstream::in);
	SimulatedDisk* simulatedDisk = new SimulatedDisk(config_file);


	if(inp.fail()){
		// FILE_SYS dose'nt exists - call a function to create a new one.

		simulatedDisk->createDisk();
		FileSystem* fs = new FileSystem();
		fs->create_root();
		delete(fs);
		cout<<"Disk Created"<<endl;


	}else{



	UI* ui = new UI();
	ui->firstUI(ui);
	ui->setUp();
	}
	inp.close();

}


